from sqlalchemy import Column, Integer, String
from sqlalchemy.orm import relationship
from app.db.session import Base
from app.models.article_tag import article_tag

class Tag(Base):
    __tablename__ = "tags"
    id = Column(Integer, primary_key=True, autoincrement=True)
    name = Column(String(50), unique=True, nullable=False)
    usage_count = Column(Integer, default=0)
    
    # 与文章的多对多关系
    articles = relationship("Article", secondary=article_tag, back_populates="tags") 